<template>
  <div class="equipment-album">
    <!-- 头部 -->
    <div class="album-header">
      <div class="album-title">
        <el-icon></el-icon>
        <span>设备相册</span>
        <span class="album-count"></span>
      </div>
    </div>
<test></test>
    <!-- 内容区域 -->
  </div>
  <Xms />
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { useCounterStore } from '@/stores/counter'
import { VideoCamera } from '@element-plus/icons-vue'
import test from '@/views/kjs/shouye/test2.vue'

//导入pinia
import axios from 'axios'
import Xms from './Xms.vue'
//获取全局变量
const counterStore = useCounterStore()
const equipmentId = ref('')
const imags = ref([])
const report = ref()
//状态
const isReady = ref(true)
//视频
const video = ref([])
//图片按钮
const tp = () => {
  isReady.value = true
}
//视频按钮
const sp =async () => {
  console.log('视频',equipmentId.value)
  const {data:response} = await axios.get(`/advertisement/equipmentVideo/${equipmentId.value}`)
  console.log('video',response.data.equipmentVideo)
  video.value = response.data.equipmentVideo
  isReady.value = false
}

    // 获取设备ID
    const getId =async () => {
      // 获取全局设备ID
      equipmentId.value = counterStore.equipmentId
    }
//获取设备图片1
    const getEquipmentImage =async () => {
      const {data:response} = await axios.get(`/advertisement/equipmentImage/${equipmentId.value}/image`)
      console.log('image',response.data.list)
      imags.value = response.data.list
    }
    // 获取设备检测表
    const getEquipmentDetection =async () => {
      const {data:response} = await axios.get(`/advertisement/detectionReport/${equipmentId.value}`)
      // 获取设备ID
            report.value = response.data
    }
    // 图片数据
    const images = ref([
      // ... 同上文的图片数据
    ])

    // 筛选条件
    const filterCategory = ref('all')

    // 计算属性：筛选后的图片列表
    const filteredImages = computed(() => {
      if (filterCategory.value === 'all') {
        return images.value
      }
      return images.value.filter(image => image.category === filterCategory.value)
    })

    // 预览图片列表
    const previewList = computed(() => {
      return filteredImages.value.map(img => img.url)
    })

    // 打开图片预览
    const openPreview = (index) => {
    }

    // 筛选图片
    const filterImages = () => {
      ElMessage.success(`已筛选: ${filterCategory.value === 'all' ? '全部图片' : filterCategory.value}`)
    }
//一进页面就调用方法
onMounted(async() => {
  //获取全局设备ID
    await getId()
    await getEquipmentImage()
    await getEquipmentDetection()
})
</script>

<style scoped>
 * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    }
    body {
      background-color: #f5f7fa;
      padding: 20px;
    }
    .equipment-album {
      max-width: 1200px;
      margin: 0 auto;
      background: white;
      border-radius: 8px;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      overflow: hidden;
    }
    .album-header {
      padding: 20px 24px;
      border-bottom: 1px solid #e8e8e8;
      background: #fafafa;
    }
    .album-title {
      font-size: 20px;
      font-weight: 600;
      color: #303133;
      display: flex;
      align-items: center;
    }
    .album-count {
      margin-left: 10px;
      font-size: 14px;
      color: #909399;
      font-weight: normal;
    }
    .album-content {
      padding: 20px;
    }
    .image-grid {
      margin-top: 20px;
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 20px;
    }
    .image-card {
      border: 1px solid #e4e7ed;
      border-radius: 6px;
      overflow: hidden;
      transition: all 0.3s ease;
      background: white;
    }
    .image-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      border-color: #409eff;
    }
    .image-container {
      position: relative;
      width: 100%;
      height: 200px;
      overflow: hidden;
      cursor: pointer;
    }
    .equipment-image {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.3s ease;
    }
    .image-container:hover .equipment-image {
      transform: scale(1.05);
    }
    .image-info {
      padding: 12px 16px;
      border-top: 1px solid #f0f0f0;
    }
    .image-title {
      font-size: 14px;
      font-weight: 600;
      color: #303133;
      margin-bottom: 4px;
    }
    .image-desc {
      font-size: 12px;
      color: #909399;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .image-category {
      background: #ecf5ff;
      color: #409eff;
      padding: 2px 6px;
      border-radius: 3px;
      font-size: 11px;
    }
    .empty-state {
      text-align: center;
      padding: 60px 20px;
      color: #909399;
    }
    .empty-icon {
      font-size: 48px;
      margin-bottom: 16px;
      color: #c0c4cc;
    }
    .filter-tabs {
      margin-bottom: 20px;
      border-bottom: 1px solid #e4e7ed;
    }
    .view-mode {
      display: flex;
      justify-content: flex-end;
      margin-bottom: 20px;
    }
    @media (max-width: 768px) {
      .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
      }
      .album-content {
        padding: 15px;
      }
    }
    @media (max-width: 480px) {
      .image-grid {
        grid-template-columns: 1fr;
      }
    }
    .tp-btn { 
      margin-top: 10px;
      width: 100px;
      background: #909399;
      border: #303133;
      &:hover {
        background: #303133;
        border: #909399;
      }
    }
    .sp-btn {
      margin-top: 10px;
      width: 100px;
      background: #909399;
      border: #303133;
      &:hover {
        background: #303133;
        border: #909399;
      }
    }
    </style>